<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGoodsSkusTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('goods_skus', function (Blueprint $table) {
            //商品sku
            $table->bigIncrements('id');
            $table->unsignedBigInteger('seller_id')->comment('商家id');
            $table->unsignedBigInteger('goods_id')->comment('商品id');
            $table->string('name',255)->comment('sku名称');
            $table->unsignedInteger('stock')->default(0)->comment('库存');
            $table->unsignedMediumInteger('price')->default(0)->comment('价格(分)');
            $table->string('thumb',255)->default('')->comment('缩略图');
            $table->string('imgs',1000)->default('')->comment('图集');
            $table->unsignedInteger('sale_num')->default(0)->comment('销量');
            $table->boolean('status')->default(true)->comment('状态1-起售0-停售');
            $table->timestamps();
            $table->foreign('seller_id')->references('id')->on('sellers')->onDelete('cascade')->onUpdate('cascade');
            $table->foreign('goods_id')->references('id')->on('goods')->onDelete('cascade')->onUpdate('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('goods_skus');
    }
}
